import { ColumnProps } from "@/components/ProTable/interface";
import { statusEnum, contentTypeEnum } from "@/config/enums/serviceDict.ts";

export function article(cateTree: any[], features: any[], origins: any[]) {
    const columns: ColumnProps[] = [
        { type: "selection", fixed: "left", width: 80 },
        { type: "index", label: "#", width: 80 },
        {
            prop: "cate_id",
            label: "分类",
            width: 150,
            fieldNames: {
                label: "name",
                value: "id"
            },
            enum: cateTree,
            search: {
                el: "tree-select",
                props: { filterable: true, label: "name", value: "id", checkStrictly: true, placeholder: "文章分类", style: "width:180px;" }
            }
        },
        {
            prop: "pics",
            label: "主图",
            width: 150,
        },
        {
            prop: "title",
            label: "标题",
            align: "left",
            width: 240,
            search: { el: "input", props: { placeholder: "请输入标题", style: "width: 180px" } }
        },
        {
            prop: "content_type",
            label: "内容格式",
            width: 120,
            enum: contentTypeEnum,
            search: { el: "select", props: { placeholder: "内容格式", style: "width: 120px" }}
        },
        {
            prop: "views",
            label: "浏览量",
            width: 100,
        },
        {
            prop: "feature",
            label: "标签",
            width: 100,
            enum: features,
            fieldNames: {
                label: 'name',
                value: 'code',
            },
            search: { el: "select", props: { placeholder: "文章标签", style: "width: 100px" }}
        },
        {
            prop: "origin",
            label: "来源",
            width: 100,
            enum: origins,
            fieldNames: {
                label: 'name',
                value: 'code',
            },
            search: { el: "select", props: { placeholder: "文章来源", style: "width: 100px" }}
        },
        {
            prop: "status",
            label: "状态",
            width: 100,
            enum: statusEnum,
            search: { el: "select", props: { placeholder: "状态", style: "width: 100px;" } }
        },
        {
            prop: "create_time",
            label: "创建时间",
            width: 180,
            search: {
                el: "date-picker",
                key: "dateTimeRange",
                props: { type: "datetimerange", valueFormat: "YYYY-MM-DD HH:mm:ss", clearable: true, style: "width: 240px;" }
            }
        },
        { prop: "operation", label: "操作", fixed: "right", width: 240 }
    ];
    return { columns };
}
